<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Hard
  </div>
  <div>
   <h1 class="question_title">
    297. Serialize and Deserialize Binary Tree
   </h1>
   <p>
    Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.
   </p>
   <p>
    Design an algorithm to serialize and deserialize a binary tree. There is no restriction on how your serialization/deserialization algorithm should work. You just need to ensure that a binary tree can be serialized to a string and this string can be deserialized to the original tree structure.
   </p>
   <p>
    <strong>
     Example:&nbsp;
    </strong>
   </p>
   <pre>
You may serialize the following tree:

    1
   / \
  2   3
     / \
    4   5

as <code>"[1,2,3,null,null,4,5]"</code>
</pre>
   <p>
    <strong>
     Clarification:
    </strong>
    The above format is the same as
    <a href="/faq/#binary-tree">
     how LeetCode serializes a binary tree
    </a>
    . You do not necessarily need to follow this format, so please be creative and come up with different approaches yourself.
   </p>
   <p>
    <strong>
     Note:&nbsp;
    </strong>
    Do not use class member/global/static variables to store states. Your serialize and deserialize algorithms should be stateless.
   </p>
  </div>
  <div>
   <h1 class="question_title">
    297. 二叉树的序列化与反序列化
   </h1>
   <p>
    序列化是将一个数据结构或者对象转换为连续的比特位的操作，进而可以将转换后的数据存储在一个文件或者内存中，同时也可以通过网络传输到另一个计算机环境，采取相反方式重构得到原数据。
   </p>
   <p>
    请设计一个算法来实现二叉树的序列化与反序列化。这里不限定你的序列 / 反序列化算法执行逻辑，你只需要保证一个二叉树可以被序列化为一个字符串并且将这个字符串反序列化为原始的树结构。
   </p>
   <p>
    <strong>
     示例:&nbsp;
    </strong>
   </p>
   <pre>你可以将以下二叉树：

    1
   / \
  2   3
     / \
    4   5

序列化为 <code>"[1,2,3,null,null,4,5]"</code></pre>
   <p>
    <strong>
     提示:&nbsp;
    </strong>
    这与 LeetCode 目前使用的方式一致，详情请参阅&nbsp;
    <a href="/faq/#binary-tree">
     LeetCode 序列化二叉树的格式
    </a>
    。你并非必须采取这种方式，你也可以采用其他的方法解决这个问题。
   </p>
   <p>
    <strong>
     说明:&nbsp;
    </strong>
    不要使用类的成员 / 全局 / 静态变量来存储状态，你的序列化和反序列化算法应该是无状态的。
   </p>
  </div>
 </body>
</html>